package cn.xsshome.algorithmNation.model;

import cn.hutool.core.codec.Base64;
import lombok.Data;
import lombok.NoArgsConstructor;


/**
 * Create by heshun on 2018/11/26
 */
@Data
@NoArgsConstructor
public class AntCipherRO {
    public static final String json = "{\n" +
            "  \"clientId\" : \"beijin_xingzhenzongdui\",\n" +
            "  \"data\" : \"i21Oz4lknsmEDKprNj4YBrD4vNjDWUjXngACEviXzIdt46ku9cT4SFIRC2i7xSklVVBZAXs86Nuly3exI6/KwaENfy6wfWvd9NFe8ifF83fCoaG13Y4ANH+tMsRbZ6BHG9ju9iyiROzF3UkwLC2o5GPfzogd6GC1+BmIXi3Q2RyiYLZZcBuJYJLoGl3fVYNSq7K8VXABuxAaMs/xK/jB3vKZKpgp1fQYZMIGqy/b/8Iv0wyhhgAN2Rd9+9Kmm5BRipXhqy4nA4Ov5i+bz+6NhK4u/1q2rFu4Nw5xDw/34+cI3wWAkzxQMARJc3aYiSd/bpLtmGvF3PuKq3ALcPzlsAdir1a/NkafqC+ZzGOqNErBsZ/GTVH3c+DhnnPBiDd6GZbmdZ+9KzEVzUGtg3Nov+3P+Y2L4PSPlx3MXHpMC+khhlVcz8uB5v63JFvszcNd4T2BOigOiU38g7+JvjJLbOn+T+9GXOjjCccmQwaRQdC/UqDruX3O5/QoxbmsMe8dM/k2gpSNKVGpAZW929jkxv/t/4T166dpjsIXzkwKzLkrzZmGegG7pq+86rDjHI2a\",\n" +
            "  \"keyData\" : \"VA6gzoik5CJfccJfYduu4eXRBRw0sg3wl12nRXbKlMNNTqffLQ7mX8pRKGc9FMbxse1r4QN7tn4MfONo6fPrKfSrLFkPgQQFlwHZrVFZWdp3LMUBVontNh3JOzCiRFtw3iOEHArCjjh59Q3Rbb8H0UrhNCWbS2kML1LZ0ZPBlg/wcKDVA7ymSfZcEOGtEnqe16CDgiPEQDBPCKGPq6MGVjaoSLgJJwF95YWRkAH9LbFrRJ2hkts6cOGJu0PpFLy4onWiwO0md5jVYHc2QvCI8kR1eE+PHbpYE2VGxC//qO1E3DZm/591nEQyXD/ENIjWhELw6+isRp+P5H6vZrU2Mw==\",\n" +
            "  \"publicKeyVersion\" : 1,\n" +
            "  \"sign\" : \"boWoS3f3vZQumlTx/lLM/0K/LfMey31Y9GPOWwKnNcWygxzDxW+13x7g6PGKPSxem+DyTDBd5RJ6A5wrIL1Ffydd5ToHnBbcc/rKh3lj0ZxqyCHuJ1qXMCWJa8p7wTKMGYYyW1TsrK5g1HRUCIjcqktugV2UEovdu1HIvXOHW2cDkryyPqm63S222thcL6t8gbezzLacgdtTyS+30+2HXUWlp+xwHwBQNCrGCdIfJjW2YeMWMvY4h+My3pHDXOvA5m9aoy79Gi63UieI3Eh12nX2hjDXvRTBkP9TcGUDxEUXnIgVmOWi7L6W7VL1Hnvahh1hq0lHCtmg6z10lUCKVw==\"\n" +
            "}";
    private String clientId;
    private int publicKeyVersion;
    private String data;
    private String keyData;
    private String sign;

//    public AntCipherRO(BigInteger clientId, int publicKeyVersion, String data, String keyData) throws Exception {
//        this.clientId = clientId.toString();
//        this.publicKeyVersion = publicKeyVersion;
//        this.data = data;
//        this.keyData = keyData;
//        this.sign = sign(clientId);
//    }

    public static AntCipherRO getRo() {
        AntCipherRO ro = new AntCipherRO();
        ro.setPublicKeyVersion(1);
        ro.setClientId("beijin_xingzhenzongdui");
        ro.setData("i21Oz4lknsmEDKprNj4YBrD4vNjDWUjXngACEviXzIdt46ku9cT4SFIRC2i7xSklVVBZAXs86Nuly3exI6/KwaENfy6wfWvd9NFe8ifF83fCoaG13Y4ANH+tMsRbZ6BHG9ju9iyiROzF3UkwLC2o5GPfzogd6GC1+BmIXi3Q2RyiYLZZcBuJYJLoGl3fVYNSq7K8VXABuxAaMs/xK/jB3vKZKpgp1fQYZMIGqy/b/8Iv0wyhhgAN2Rd9+9Kmm5BRipXhqy4nA4Ov5i+bz+6NhK4u/1q2rFu4Nw5xDw/34+cI3wWAkzxQMARJc3aYiSd/bpLtmGvF3PuKq3ALcPzlsAdir1a/NkafqC+ZzGOqNErBsZ/GTVH3c+DhnnPBiDd6GZbmdZ+9KzEVzUGtg3Nov+3P+Y2L4PSPlx3MXHpMC+khhlVcz8uB5v63JFvszcNd4T2BOigOiU38g7+JvjJLbOn+T+9GXOjjCccmQwaRQdC/UqDruX3O5/QoxbmsMe8dM/k2gpSNKVGpAZW929jkxv/t/4T166dpjsIXzkwKzLkrzZmGegG7pq+86rDjHI2a");
        ro.setKeyData("VA6gzoik5CJfccJfYduu4eXRBRw0sg3wl12nRXbKlMNNTqffLQ7mX8pRKGc9FMbxse1r4QN7tn4MfONo6fPrKfSrLFkPgQQFlwHZrVFZWdp3LMUBVontNh3JOzCiRFtw3iOEHArCjjh59Q3Rbb8H0UrhNCWbS2kML1LZ0ZPBlg/wcKDVA7ymSfZcEOGtEnqe16CDgiPEQDBPCKGPq6MGVjaoSLgJJwF95YWRkAH9LbFrRJ2hkts6cOGJu0PpFLy4onWiwO0md5jVYHc2QvCI8kR1eE+PHbpYE2VGxC//qO1E3DZm/591nEQyXD/ENIjWhELw6+isRp+P5H6vZrU2Mw==");
        ro.setSign("boWoS3f3vZQumlTx/lLM/0K/LfMey31Y9GPOWwKnNcWygxzDxW+13x7g6PGKPSxem+DyTDBd5RJ6A5wrIL1Ffydd5ToHnBbcc/rKh3lj0ZxqyCHuJ1qXMCWJa8p7wTKMGYYyW1TsrK5g1HRUCIjcqktugV2UEovdu1HIvXOHW2cDkryyPqm63S222thcL6t8gbezzLacgdtTyS+30+2HXUWlp+xwHwBQNCrGCdIfJjW2YeMWMvY4h+My3pHDXOvA5m9aoy79Gi63UieI3Eh12nX2hjDXvRTBkP9TcGUDxEUXnIgVmOWi7L6W7VL1Hnvahh1hq0lHCtmg6z10lUCKVw==");
        return ro;
    }

//    private String sign(BigInteger clientId) throws Exception {
//        String sign = publicKeyVersion + this.clientId + Base64.encode(data) + Base64.encode(keyData);
//        return SM2VerifySign.Sign2SM2(sign.getBytes(), clientId).sm2_sign;
//    }

    public static void main(String[] args) {
        System.out.println(Base64.decodeStr(getRo().getData()));
    }

    public String getSignData() {
        return publicKeyVersion + clientId + data + keyData;
    }
}
